home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 October / Macformat17.cdr / Shareware City / Developers / MacAppMods1.0d3 / MODs < prev   
Encoding:
Text File  |  1994-06-25  |  13.1 KB  |  482 lines  |  [TEXT/MMCC]

  1. Modifications to MacApp 3.1 for CodeWarrior
  2. 1.0d3    6/25/94        Please see @@@, below, for an important typo.  
  3.                     Also please note that the fixes for 6-13-94 MPTP compiler only
  4.                     affect that compiler.  Earlier and later versions don't have
  5.                     the problem.
  6. 6/22/94
  7. ••••••••••••••••••••••••••••••
  8. in UMenuMgr.cp replace the *h to *pHNullMenuProc in: (search for BlockMove until
  9. you find the commented out version and replace it with the 2nd version)
  10. //••JS•• said original is a bug in System 7.5
  11. //    BlockMove(&aMDEFUPP, *h, sizeof(RoutineDescriptor));
  12.     BlockMove(&aMDEFUPP, *pHNullMenuProc, sizeof(RoutineDescriptor));
  13.     
  14. ••••••••••••••••••••••••••••••
  15. In UMenuMgr.cp change original to:
  16. //----------------------------------------------------------------------------------------
  17. // EndMenuSetup: 
  18. //----------------------------------------------------------------------------------------
  19. void EndMenuSetup(MenuHandle aMenuHandle,
  20.                   Boolean isHierarchical,
  21.                   void* staticLink)
  22.  
  23. {
  24.     long newFlags;
  25.  
  26.     if (IsSetupMenu(aMenuHandle, isHierarchical))
  27.     {
  28.         newFlags = (*aMenuHandle)->enableFlags;
  29.         // If any items are enabled, enable the menu 
  30.         if (newFlags != 0)
  31.         {
  32.             newFlags = (1 | newFlags);
  33.             (*aMenuHandle)->enableFlags = newFlags;
  34.         }
  35.  
  36.         // If the menu's enabled state changed, we have to draw the menu bar. 
  37.         if (((newFlags & 1) == 1) != ((SetupStructPtr)staticLink)->wasEnabled[(*aMenuHandle)->menuID])
  38.             InvalidateMenuBar();
  39.  
  40.         // Restore the menuproc. 
  41.         (*aMenuHandle)->menuProc = ((SetupStructPtr)staticLink)->savedProcs[(*aMenuHandle)->menuID];
  42.         
  43.         // menuWidth set to 0 by routines that require CalcMenuSize, by
  44.         // calling NeedCalcMenu.
  45.         //See workaround below
  46.         //if (!(*aMenuHandle)->menuWidth)
  47.         //    CalcMenuSize(aMenuHandle);
  48.     }
  49.     //•••JS Bug workaround•••
  50.     // menuWidth set to 0 by routines that require CalcMenuSize, by
  51.     // calling NeedCalcMenu.
  52.     if (!(*aMenuHandle)->menuWidth)
  53.         CalcMenuSize(aMenuHandle);
  54. } // EndMenuSetup 
  55.  
  56.  
  57. ••••••••••••••••••••••••••••••
  58.  
  59. in PascalString.h change original to:
  60.     friend inline Boolean operator==(const CString& s1,
  61.                               const char* s2);
  62.     friend inline Boolean operator==(const char* s1,
  63.                               const CString& s2);
  64.     friend inline Boolean operator==(const CString& s1,
  65.                               const CString& s2);
  66.  
  67.     friend inline Boolean operator!=(const CString& s1,
  68.                               const char* s2);
  69.     friend inline Boolean operator!=(const char* s1,
  70.                               const CString& s2);
  71.     friend inline Boolean operator!=(const CString& s1,
  72.                               const CString& s2);
  73.  
  74.     friend inline Boolean operator>(const CString& s1,
  75.                              const char* s2);
  76.     friend inline Boolean operator>(const char* s1,
  77.                              const CString& s2);
  78.     friend inline Boolean operator>(const CString& s1,
  79.                              const CString& s2);
  80.  
  81.     friend inline Boolean operator<(const CString& s1,
  82.                              const char* s2);
  83.     friend inline Boolean operator<(const char* s1,
  84.                              const CString& s2);
  85.     friend inline Boolean operator<(const CString& s1,
  86.                              const CString& s2);
  87.  
  88.     friend inline Boolean operator>=(const CString& s1,
  89.                               const char* s2);
  90.     friend inline Boolean operator>=(const char* s1,
  91.                               const CString& s2);
  92.     friend inline Boolean operator>=(const CString& s1,
  93.                               const CString& s2);
  94.  
  95.     friend inline Boolean operator<=(const CString& s1,
  96.                               const char* s2);
  97.     friend inline Boolean operator<=(const char* s1,
  98.                               const CString& s2);
  99.     friend inline Boolean operator<=(const CString& s1,
  100.                               const CString& s2);
  101.  
  102. Be careful to only replace the "friends" listed here.  There should be 18.  This change is
  103. necessary to be compatable with CW3.5
  104. ••••••••••••••••••••••••••••••
  105.  
  106. IMPORTANT This change is only necessary for the 6-13-94 build of the compiler.  Only
  107. MW beta testers have this version (MPTP members); later MPTP versions have fixed the bug.  
  108. All other users can ignore it.
  109.  
  110. In PascalString.h change original to: (I've included a line or 2 above and below the
  111. necessary change)
  112.  
  113.     // Used to create a toolbox type Str255 from our CString. This is simply a type
  114.     // coercion! Both CString and Str255 are expected to be pascal-style strings.
  115.  
  116. //needed for CW Bug; defined in MacAppHeaders940613.cp
  117. #ifdef _940613CWBug    
  118.     inline operator unsigned char*();
  119. /*
  120. //The following needs to be put in PascalString.cp; N.B. inline isn't used
  121. CString::operator unsigned char*()
  122. {
  123.     return (unsigned char *) this;
  124. }                                            // for non-const CString
  125. */
  126. #else
  127.     inline operator unsigned char*()
  128.     {
  129.         return (unsigned char *) this;
  130.     }                                            // for non-const CString
  131. #endif    
  132.     operator const unsigned char*() const;        // for const CString
  133.  
  134.     //------------------------------------------------------------------------------------
  135. ••••••••••••••••••••••••••••••
  136. IMPORTANT This change is only necessary for the 6-13-94 build of the compiler.  Only
  137. MW beta testers have this version (MPTP members); later MPTP versions have fixed the bug.  
  138. All other users can ignore it.
  139.  
  140. @@@ In PascalString.cp put the following anywhere (such as just after the #includes): 
  141.  
  142. //added for a CW Bug in the 6-13-94 MPTP compiler
  143. //it only affects code in PascalString.cp and .h
  144.  
  145. #ifdef _940613CWBug
  146.  CString::operator unsigned char*()
  147. {
  148.     return (unsigned char *) this;
  149. }                                            // for non-const CString
  150. #endif
  151.  
  152.  
  153. ••••••••••••••••••••••••••••••
  154.  
  155.  
  156. In UObject.h change original to
  157. //----------------------------------------------------------------------------------------
  158. // TObject: Definition of the system's root object
  159. //----------------------------------------------------------------------------------------
  160.  
  161. DeclareClassDesc(TObject);
  162.  
  163. // ••• JS NEW ••• singleobject + forceclassidfirst + classdescmany
  164.  
  165. #if qMultipleInheritance || qPowerPC || defined(__MWERKS__) || defined(THINK_C) || defined(__SC__)
  166.    #if (qDebug || qSym) && defined(__MWERKS__)
  167.    // make sure CodeWarrior puts fClassID first, not the vtable
  168.    struct ForceClassIDFirst
  169.    {
  170.       ClassID fClassID;
  171.    };
  172.    class TObject : public ForceClassIDFirst
  173.    #else
  174.    // assume the other compilers already put fClassID first (for Jasik)
  175.    class TObject
  176.    #endif
  177. #else
  178.    // for MPW C only and no MI, descend from SingleObject, so vtables are smaller
  179.    class TObject : public SingleObject
  180. #endif
  181. {
  182.    DeclareClass(TObject);
  183.  
  184. public:
  185.  
  186. #if (qDebug || qSym) && !defined(__MWERKS__)
  187.    ClassID fClassID;   // Used to do object validation in debug mode.
  188. #endif
  189.  
  190.     //------------------------------------------------------------------------------------
  191.     // Initializer and I<Method>.
  192.     //------------------------------------------------------------------------------------
  193.  
  194. ••••••••••••••••••••••••••••••
  195. In UDebug.h change original to
  196. class CStackFrame
  197. {
  198. private: // data fields
  199.     ptrdiff_t fFramePtr;
  200.  
  201. public: // methods
  202.     CStackFrame(void* framePtr);
  203.     CStackFrame(long framePtr = 1);
  204. //CK
  205. #if !__MWERKS__
  206.     CStackFrame(ptrdiff_t framePtr);
  207. //CK
  208. #endif
  209.  
  210. ••••••••••••••••••••••••••••••
  211. In UDebug.cp change original to
  212. //CK
  213. #if !__MWERKS__
  214. //----------------------------------------------------------------------------------------
  215. // CStackFrame::CStackFrame:
  216. //----------------------------------------------------------------------------------------
  217. CStackFrame::CStackFrame(ptrdiff_t framePtr)
  218. {
  219.     fFramePtr = framePtr;
  220. } // CStackFrame::CStackFrame
  221. //CK
  222. #endif
  223. •••
  224. //CK
  225.  #if !qPowerPC  && !__MWERKS__
  226. //was #if !qPowerPC 
  227.  
  228.             case 'segu':
  229.                 gUnloadAllSegs = !gUnloadAllSegs;
  230.                 break;
  231.                 
  232. #endif
  233. •••
  234. //CK
  235.  #if !qPowerPC  && !__MWERKS__
  236. //was #if !qPowerPC
  237.  
  238.     ((TCheckBox *) this->FindSubView('segu'))->SetState(gUnloadAllSegs, false);
  239. #endif    
  240. •••
  241. void ShowSegments()
  242. {
  243. //CK
  244. #if !qPowerPC  && !__MWERKS__ 
  245. //was #if !qPowerPC
  246.  
  247.  
  248. ••••••••••••••••••••••••••••••
  249. Put the following in UFailure.cp just above the function Assertion()
  250.  
  251. //CW currently can't output to stderr.  What follows is a kludge that puts the message 
  252. //in a window of the Scriptable Text Editor through AppleScript.
  253. //You must 'manually' open a window in Scriptable Text Editor for this code to work.
  254.  #if __MWERKS__  && qDebug
  255.  
  256. #include <AppleEvents.h>
  257. #include <AERegistry.h>
  258. #include <AEObjects.h>
  259. #include <AEPackObject.h>
  260. #include <stdarg.h>
  261.  
  262.  
  263. pascal OSErr SetText( AEDesc    *txtDesc, char * theText) //put the string into the appleEvent
  264.     {
  265.             OSErr    myErr;
  266.             
  267.             myErr = AECreateDesc(typeChar,(Ptr)&theText[1], theText[0], txtDesc);
  268.             
  269.             
  270.             return(myErr);
  271.             
  272.     } /*MakeWindowObj*/
  273. pascal OSErr MakeWindowNumberObj( AEDesc    *dMyDoc) //make the outermost container
  274.     {
  275.             AEDesc   dNull;
  276.             AEDesc   dDoc;
  277.             OSErr    myErr;
  278.             long    keyData = 1;
  279.             DescType    myKeyForm = formAbsolutePosition;
  280.             
  281.             myErr = AECreateDesc(typeLongInteger,(Ptr)&keyData, sizeof(keyData), &dDoc);
  282.             
  283.             if (myErr==noErr) 
  284.                 myErr = AECreateDesc(typeNull, nil , 0, &dNull); //signals that this is outermost
  285.             
  286.             if (myErr==noErr) 
  287.                 myErr = CreateObjSpecifier(cWindow /*a window*/, &dNull, myKeyForm, &dDoc, true, dMyDoc);
  288.             
  289.             return(myErr);
  290.             
  291.     } /*MakeWindowNumberObj*/
  292. pascal OSErr MakeParaNumberObj( AEDesc    *dMyDoc, long i) //make the innermost container
  293.     {
  294.             AEDesc   dDoc;
  295.             OSErr    myErr;
  296.             long    keyData = i;
  297.             DescType    myKeyForm = formAbsolutePosition;
  298.             AEDesc   wind;
  299.             
  300.             MakeWindowNumberObj( &wind);//make the outermost container
  301.             
  302.             myErr = AECreateDesc(typeLongInteger,(Ptr)&keyData, sizeof(keyData), &dDoc);
  303.             
  304.             
  305.             if (myErr==noErr) 
  306.                 myErr = CreateObjSpecifier('cpar'/*a paragraph*/, &wind, myKeyForm, &dDoc, true, dMyDoc);
  307.             
  308.             return(myErr);
  309.             
  310.     } /*MakeParaNumberObj*/
  311.  
  312. static Boolean sendMessageToStderr (OSType appid, OSType eventclass, OSType eventid, char * tmp) {
  313.     
  314.     AEAddressDesc adr = {typeNull, nil}; 
  315.     AppleEvent writeIt = {typeNull, nil}; 
  316.     AppleEvent selectIt = {typeNull, nil};
  317.     AppleEvent reply1 = {typeNull, nil};
  318.     AppleEvent reply2 = {typeNull, nil};
  319.     OSErr ec;
  320.     AEDesc    dMyDoc;
  321.     AEDesc    txtDesc;
  322.     //AEDesc    slctDesc;
  323.     static    long    paragraphNum = 1;
  324.     /*1. create the Apple Event, address it to the Scriptable Text Editor app*/ 
  325.         ec = AECreateDesc (typeApplSignature, (Ptr) &appid, sizeof (appid), &adr);
  326.         
  327.         if (ec != noErr)
  328.             goto error;
  329.             
  330.         ec = AECreateAppleEvent (
  331.             eventclass, eventid, &adr, 
  332.             
  333.             0, 0, 
  334.             
  335.             &writeIt);
  336.             
  337.         if (ec != noErr)
  338.             goto error;
  339.         ec = AECreateAppleEvent (
  340.             'misc', 'slct', &adr, 
  341.             
  342.             0, 0, 
  343.             
  344.             &selectIt);
  345.             
  346.         if (ec != noErr)
  347.             goto error;
  348.         
  349.         //create the object container
  350.         ec = MakeParaNumberObj(  &dMyDoc, paragraphNum++ );
  351.         
  352.         //make the container a part of the events
  353.         if (AEPutParamDesc (&writeIt, keyDirectObject, &dMyDoc) != noErr)
  354.             goto error;
  355.         if (AEPutParamDesc (&selectIt, keyDirectObject, &dMyDoc) != noErr)
  356.             goto error;
  357.         
  358.     
  359.             
  360.         ec = SetText( &txtDesc, tmp);
  361.  
  362.         if (AEPutParamDesc (&writeIt, keyAEData, &txtDesc) != noErr)
  363.             goto error;
  364.         
  365.     /*2. send the message, don't wait for a reply*/ {
  366.         
  367.         //send the string
  368.         ec = AESend (        
  369.             &writeIt, &reply1,  kAENoReply , 
  370.             
  371.             kAENormalPriority,  kNoTimeOut, nil, nil);
  372.             
  373.         if (ec != noErr)
  374.             goto error;
  375.         
  376.         //selcet the string so that it autoscrolls
  377.         ec = AESend (        
  378.             &selectIt, &reply2,  kAENoReply , 
  379.             
  380.             kAENormalPriority,  kNoTimeOut, nil, nil);
  381.             
  382.         if (ec != noErr)
  383.             goto error;
  384.         }
  385.     
  386.     AEDisposeDesc (&writeIt);
  387.         
  388.     AEDisposeDesc (&selectIt);    
  389.     
  390.     AEDisposeDesc (&reply1);
  391.     
  392.     AEDisposeDesc (&reply2);    
  393.     
  394.     AEDisposeDesc (&dMyDoc);
  395.     
  396.     AEDisposeDesc (&txtDesc);
  397.  
  398.     return (true);
  399.     
  400.     error:
  401.     
  402.     /*report the error code using ProgramBreak*/ {
  403.         
  404.         Str255 s;
  405.         
  406.         NumToString (ec, s);
  407.         
  408.         ProgramBreak (s);
  409.         }
  410.     
  411.     AEDisposeDesc (&writeIt);
  412.         
  413.     AEDisposeDesc (&selectIt);    
  414.     
  415.     AEDisposeDesc (&reply1);
  416.     
  417.     AEDisposeDesc (&reply2);    
  418.     
  419.     AEDisposeDesc (&dMyDoc);
  420.     
  421.     AEDisposeDesc (&txtDesc);
  422.  
  423.     return (false);
  424.     } /*sendMessageToStderr*/
  425.  
  426. int CWfprintf(FILE * /*ignore*/, const char * format, ...)
  427. {
  428.  
  429.     va_list    ap = NULL;
  430.     int        result;
  431.     char     tmp[512];    //temp storage for output string
  432.     static char    str[512];    //we will concatenate strings until we find a return character
  433.     char    fail[] = "\pvsprintf failed\n";
  434.     short i;
  435.     static long len = 0;    //length of string we are concatenating 
  436.     
  437.     Boolean        haveApplescript = true; //set to false if you want to output to Jasik's debugger
  438.  
  439.     va_start(ap, format );    
  440.     result = vsprintf(tmp, format, ap );
  441.     va_end(ap);
  442.     if ( result >= 0 ) //we were able to convert the fprintf "string" into a C string
  443.     {
  444.         strcat( &str[1], tmp ); 
  445.         len = strlen(&str[1]); //use [1] because our AppleEvent will be using a Str255
  446.         if (len > 254 ) //see previous comment
  447.         {
  448.             str[0] = 255;
  449.             str[255] = 0x0D;
  450.         }
  451.         else
  452.         {
  453.             str[0] = len;        
  454.             if ( str[len] == 0x0A ) // vprintf converts the \n to a linefeed; 
  455.                 str[len] = 0x0D;    //we need to change it back to a \n
  456.             else
  457.                 return (result);      //don't send the AE yet, we haven't received the \n
  458.                             
  459.         }
  460.     }
  461.     else
  462.         strcpy(str, fail);  //something went wrong
  463.  
  464.     
  465.     if (haveApplescript)
  466.         sendMessageToStderr ('quil' /*Scritable Text Editor*/, 'core' /*Core suite*/, 
  467.         'setd'/*Set Data*/, str);
  468.     else
  469.            ProgramBreak(&str[1]); //send to Jasik's debugger
  470.     for (i = 0; i <4; i++ )    //initialize string
  471.         str[i] = 0;            //more than enough zeros to set the length to zero
  472.     len = 0;                //initialize length
  473.     return (result);
  474.     
  475. }
  476. #endif //__MWERKS__
  477. //----------------------------------------------------------------------------------------
  478. // Assertion: 
  479. //----------------------------------------------------------------------------------------
  480. •••••••••••••••••••••••
  481.  
  482.